package com.yloveg.controller;

import com.yloveg.base.BaseController;
import com.yloveg.common.FreemarkUtil.PaymentType;
import com.yloveg.entity.PaymentConfigure;
import com.yloveg.entity.SRole;
import com.yloveg.service.PaymentConfigureService;

import org.apache.commons.collections4.map.HashedMap;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.Map;


@Controller
@RequestMapping("/payment")
public class PaymentController extends BaseController {
    private final Logger logger = Logger.getLogger(this.getClass());
    
    
    @Autowired
    private PaymentConfigureService paymentConfigureService;
    
    /**
     * 保存角色信息
	* @param info
	* @return
	*/
	@RequestMapping("/saveUpZfbConfigure")
	@ResponseBody
	public Map<String, Object> saveUpRole(PaymentConfigure configure){
		Map<String, Object> map = new HashedMap<String, Object>();
		int result = 0;
		if(configure.getId()==0){
			configure.setConfigureType(PaymentType.ZFBH5.getValue());
			configure.setUserId(this.getSessionUser().getId());
			result = paymentConfigureService.insert(configure);
		}else{
			result = paymentConfigureService.update(configure);
		}
		if(result>0){
			map.put("code", "1");
			map.put("msg", "操作成功！");
		}else {
			map.put("code", "0");
			map.put("msg", "系统错误请联系管理员！");
		}
		return map;		
	}
}
